package com.bwie.controller;

import com.bwie.pojo.TbActive;
import com.bwie.pojo.TbWinRecord;
import com.bwie.service.TbActiveService;
import com.bwie.service.TbWinRecordService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/team/second")
public class RuleController {

     @Autowired
     TbActiveService tbActiveService;

     @Autowired
    TbWinRecordService tbWinRecordService;

    @ApiOperation("活动分页")
    @PostMapping("/ActivePageList")
    public R ActivePageList(@RequestBody PageInfoVo pageInfoVo){
        return tbActiveService.TeamPageList(pageInfoVo);
    }

    @ApiOperation("添加")
    @PostMapping("/activeAdd")
    public R activeAdd(@RequestBody TbActive tbActive){
        return tbActiveService.insert(tbActive);
    }

    @ApiOperation("修改活动")
    @PostMapping("/updateActive")
    public R updateActive(@RequestBody TbActive tbActive){
       return tbActiveService.updateActive(tbActive);
    }

    @ApiOperation("删除活动")
    @PostMapping("/deleteActive")
    public R deleteActive(@RequestParam("activeId") Integer activeId){
        return tbActiveService.delete(activeId);
    }

     @ApiOperation("记录表")
     @PostMapping("/getRecordList")
     public R getRecordList(@RequestBody PageInfoVo pageInfoVo){
        return tbWinRecordService.getRecordList(pageInfoVo);
     }

     @ApiOperation("根据创建活动id进行查询")
     @PostMapping("/getRuleListById/{activeId}")
    public R getRuleListById(@PathVariable(name = "activeId")Integer activeId){
        return tbActiveService.getRuleList(activeId);
     }
  }
